package com.example.demo.Enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * The enum Sex enum.
 * 性别枚举
 */
@Getter
@AllArgsConstructor
//不加该注解查询返回的数据是构造器名称  示例：男则返回 -> MAN
//@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum SexEnum {
    MAN(1, "男"),
    WOMAN(0, "女");

    @EnumValue
    private final Integer code;
    private final String sexStr;

    public static SexEnum valueOf(Integer code) {
        for (SexEnum value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }
}
